import { Rule } from "./types";

export const PerformanceRuleList: Rule[] = [
    {
        id: "ArrayPrimitive",
        descEn: `Using Array<Primitive> leads to implicit boxing and performance hit. Prefer using Kotlin specialized Array Instances.

        As stated in the Kotlin documentation Kotlin has specialized arrays to represent primitive types without boxing overhead, such as IntArray, ByteArray and so on.`,
        descCn: "",
        active: true,
        debt: "5min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/performance#arrayprimitive",
    },
    {
        id: "CouldBeSequence",
        descEn: "Long chains of collection operations will have a performance penalty due to a new list being created for each call. Consider using sequences instead. ",
        descCn: "",
        active: false,
        debt: "5min",
        paramList: [
            {
                param: "threshold",
                descEn: "the number of chained collection operations required to trigger rule",
                descCn: "",
                defaultValue: 3,
            }
        ],
        url: "https://detekt.dev/docs/rules/performance#couldbesequence",
    },
    {
        id: "ForEachOnRange",
        descEn: `Using the forEach method on ranges has a heavy performance cost. Prefer using simple for loops.

        Benchmarks have shown that using forEach on a range can have a huge performance cost in comparison to simple for loops. Hence, in most contexts, a simple for loop should be used instead. `,
        descCn: "",
        active: true,
        debt: "5min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/performance#foreachonrange",
    },
    {
        id: "SpreadOperator",
        descEn: `In most cases using a spread operator causes a full copy of the array to be created before calling a method. This has a very high performance penalty. 

        The Kotlin compiler since v1.1.60 has an optimization that skips the array copy when an array constructor function is used to create the arguments that are passed to the vararg parameter. When type resolution is enabled in detekt this case will not be flagged by the rule since it doesn't suffer the performance penalty of an array copy.
        `,
        descCn: "",
        active: true,
        debt: "20min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/performance#spreadoperator",
    },
    {
        id: "UnnecessaryPartOfBinaryExpression",
        descEn: "Unnecessary binary expression add complexity to the code and accomplish nothing. They should be removed. The rule works with all binary expression included if and when condition. The rule also works with all predicates. The rule verify binary expression only in case when the expression use only one type of the following operators || or &&.",
        descCn: "",
        active: false,
        debt: "5min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/performance#unnecessarypartofbinaryexpression",
    },
    {
        id: "UnnecessaryTemporaryInstantiation",
        descEn: "Avoid temporary objects when converting primitive types to String. This has a performance penalty when compared to using primitive types directly. To solve this issue, remove the wrapping type.",
        descCn: "",
        active: true,
        debt: "5min",
        paramList: [],
        url: "https://detekt.dev/docs/rules/performance#unnecessarytemporaryinstantiation",
    },
];